package com.dk.logc.utils;

public enum ErrorCode {
    SUCCESS(1, "成功"),
    ERROR(-101, "错误"),
    ERR_PARAM(-102, "参数错误"),
    ERR_NULL_VAL(-103, "空值"),
    ERR_TIMEOUT(-104, "超时"),
    ERR_SIGN(-105, "签名错误"),
    ERR_EXISTS(-106, "已存在"),
    ERR_INSUFF(-107, "余量不足"),
    ERR_FORBID(-108, "已封禁"),
    ERR_NOT_EXISTS(-109, "不存在"),
    ERR_USED(-110, "已使用"),
    ERR_ORDER_NOT_FOUND(-111, "找不到订单"),
    ERR_ORDER_CLOSED(-112, "订单已关闭"),
    ERR_ORDER_ABNORMAL(-113, "订单状态异常"),
    ERR_ORDER_ABNORMAL_AMOUNT(-114, "订单金额异常"),
    ERR_NOT_LOGIN(-115, "未登录"),
    ERR_DB_FAIL(-116, "数据库异常"),
    ERR_REQ_TIMEOUT(-117, "请求超时"),
    ERR_ALREADY_RECEIVED(-118, "已领取"),
    ERR_STATUS(-119, "状态错误");

    private int code;
    private String msg;

    private ErrorCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public boolean isSuccess() {
        return this.getCode() == SUCCESS.getCode();
    }

    public boolean isFail() {
        return !this.isSuccess();
    }

    public static ErrorCode valueOf(int code) {
        ErrorCode[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            ErrorCode errorCode = var1[var3];
            if (errorCode.getCode() == code) {
                return errorCode;
            }
        }

        return null;
    }

    public String toString() {
        return this.code + "|" + this.msg;
    }

    public int getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }
}
